var app = getApp()
Component({
  data: {
    statusBarHeight: '',
    titleBarHeight: '',
    isShowHome: false,
    selectedIndex: 0
  },
  properties: {
    //属性值可以在组件使用时指定
    isNavShow: {
      type: Boolean,
      value: false
    },
    isAddBtnShow: {
      type: Boolean,
      value: false
    },
    title: {
      type: String,
      value: ''
    },
    bgColor: {
      type: String,
      value: '#fff'
    },
    fontColor: {
      type: String,
      value: '#000'
    },
    items: {
      type: Array,
      value: []
    },
    badgeNum: {
      type: Number,
      value:0
    },
    isActive: {
      type: Boolean,
      value: false
    }
  },
  attached() {
    let pageContext = getCurrentPages()
    if (pageContext.length > 1) {
      this.setData({
        isShowHome: false
      })
    } else {
      this.setData({
        isShowHome: true
      })
    }
    this.setData({
      statusBarHeight: app.globalData.statusBarHeight,
      titleBarHeight: app.globalData.titleBarHeight
    })
    console.log(app.globalData.statusBarHeight)
    console.log(app.globalData.titleBarHeight)
  },
  methods: {
    topNavTap(e) {
      // console.log("topNavTap");
      const data = e.currentTarget.dataset;
      var selectedIndex = data.index;
      this.setData({
        selectedIndex: selectedIndex,
      });
      this.triggerEvent('topNavTap', {"selectedIndex":selectedIndex});
    },
    addBtnTap() {
      this.triggerEvent('addBtnTap', {});
    }
  }
})